package org.example.yunshu.demos.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.yunshu.demos.model.UserInfo;
import org.example.yunshu.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.w3c.dom.UserDataHandler;

import javax.servlet.http.HttpSession;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService ;

    @RequestMapping("/login")
    public Object login(UserInfo userInfo , String inputCaptcha, HttpSession session){
        return userService.login(userInfo ,inputCaptcha,  session) ;
    }

    @RequestMapping("/register")
    public Object register(UserInfo userInfo , String inputCaptcha, HttpSession session){
       return userService.insertUserInfo(userInfo ,inputCaptcha , session) ;
    }

     @RequestMapping("/getUserInfo")
    public Object getUserInfo(HttpSession httpSession){
         return userService.getUserInfo(httpSession) ;
     }


     // 同意好友申请
     @RequestMapping("/agree")
     public Object agree(Integer userId , Integer fromId){
         return userService.agree(userId , fromId) ;
     }


     // 拒绝好友申请
     @RequestMapping("/refuse")
    public Object refuse(Integer userId , Integer fromId){
      return userService.refuse(userId , fromId) ;
     }

}
